/**
 * @param {number} n
 * @param {number} target
 * @return {number}
 */
var minimumPossibleSum = function (n, target) {
    let mid = Math.floor(target / 2)

    if(mid>n){
        console.log((1 + n) * n / 2 %1000000007);
        return (1 + n) * n / 2 %1000000007
    }
    let front = (1 + mid) * mid / 2

    console.log(front);
    let midAfter = n-mid
    let behind = (midAfter-1) * midAfter / 2 + target*midAfter
    console.log(behind);
    return (front+behind)%1000000007

};

minimumPossibleSum(5, 8)
// minimumPossibleSum(3, 3)
// minimumPossibleSum(0, 4)
// minimumPossibleSum(0, 8)
// minimumPossibleSum(0, 10)